public class TestDemo {
    public static int fib(int n) {
        int fib1=0;
        int fib2=1;
        int fib3=1;
        if(n==0){
            return 0;
        }
        if(n==1){
            return 1;
        }
        if (n == 2) {
            return 1;
        }

        for(int i=3;i<=n;i++){
            fib3=fib1+fib2;
            fib1=fib2;
            fib2=fib3;
        }
        return fib3;

    }

    public static void main(String[] args) {
        System.out.println(fib(20));
    }

}
